from typing import Any

from core.match_item import MatchItem
from core.simple_equals import SimpleEquals


class NumberValueMatchItem(MatchItem):

    __slots__ = [
        'source',
        'value',
        'equals'
    ]

    def __init__(self, source: int, value: Any):
        self.source = source
        self.value = value
        self.equals = SimpleEquals()

    @property
    def source_index(self):
        return self.source - 1

    def is_match(self, a: tuple, b: tuple) -> bool:
        return self.equals.equal(b[self.source_index], self.value)
